/*
 * description
 */
package com.ztk.coding.commons.pool2;

import org.apache.commons.pool2.impl.GenericObjectPoolConfig;

/**
 * 类的描述
 *
 * @author ztkool
 * @version v
 */
public class Test {

    public static void main(String[] args) throws Exception {
        ConnectionFactory orderFactory = new ConnectionFactory();
        GenericObjectPoolConfig config = new GenericObjectPoolConfig();
        config.setMaxTotal(5);
        //设置获取连接超时时间
        config.setMaxWaitMillis(1000);
        ConnectionPool connectionPool = new ConnectionPool(orderFactory, config);
        for (int i = 0; i < 7; i++) {
            Connection o = connectionPool.borrowObject();
            System.out.println("brrow a connection: " + o + " active connection:" + connectionPool.getNumActive());
//            connectionPool.returnObject(o);
        }
    }

}
